home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / xml / EntityDeclaration.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  3.5 KB  |  120 lines

  1. package com.extensibility.xml;
  2.  
  3. import com.extensibility.util.Debug;
  4. import com.extensibility.util.StringUtilities;
  5. import java.util.Vector;
  6.  
  7. public abstract class EntityDeclaration extends BaseDeclaration implements Cloneable {
  8.    String publicID;
  9.    URI systemID;
  10.    String value;
  11.  
  12.    public EntityDeclaration(String var1, String var2, URI var3) {
  13.       super(var1);
  14.       this.publicID = var2;
  15.       this.systemID = var3;
  16.    }
  17.  
  18.    public EntityDeclaration(String var1, String var2) {
  19.       super(var1);
  20.       this.value = var2;
  21.    }
  22.  
  23.    public Object clone() {
  24.       EntityDeclaration var1 = null;
  25.  
  26.       try {
  27.          var1 = (EntityDeclaration)super.clone();
  28.       } catch (CloneNotSupportedException var3) {
  29.          Debug.assert(false, "Problem cloning EntityDeclaration.");
  30.       }
  31.  
  32.       return var1;
  33.    }
  34.  
  35.    public String getPublicID() {
  36.       return this.publicID;
  37.    }
  38.  
  39.    public URI getSystemID() {
  40.       return this.systemID;
  41.    }
  42.  
  43.    public Vector getPrerequisites(SchemaIntf var1) {
  44.       Vector var2 = super.getPrerequisites(var1);
  45.       BaseDeclaration.addPrerequisite(var1, var2, this.value, true);
  46.       BaseDeclaration.addPrerequisite(var1, var2, this.value, false);
  47.       BaseDeclaration.addPrerequisite(var1, var2, this.publicID, true);
  48.       BaseDeclaration.addPrerequisite(var1, var2, this.systemID == null ? null : this.systemID.toSource(), true);
  49.       return var2;
  50.    }
  51.  
  52.    public boolean references(InternalPEDeclaration var1) {
  53.       String var2 = String.valueOf("%").concat(String.valueOf(var1));
  54.       if (this.value != null && this.value.indexOf(var2) >= 0) {
  55.          return true;
  56.       } else if (this.publicID != null && this.publicID.indexOf(var2) >= 0) {
  57.          return true;
  58.       } else {
  59.          return this.systemID != null && this.systemID.toSource().indexOf(var2) >= 0;
  60.       }
  61.    }
  62.  
  63.    public void setPublicID(String var1) {
  64.       String var2 = this.publicID;
  65.       this.publicID = var1;
  66.       this.value = null;
  67.       ((BaseDeclaration)this).fireChangeEvent(53, var2);
  68.    }
  69.  
  70.    public void setSystemID(URI var1) {
  71.       Debug.assert(var1 != null, "sys must be non-null for entities");
  72.       URI var2 = this.systemID;
  73.       this.systemID = var1;
  74.       this.value = null;
  75.       ((BaseDeclaration)this).fireChangeEvent(52, var2);
  76.    }
  77.  
  78.    public String getValue() {
  79.       return this.value;
  80.    }
  81.  
  82.    public void checkForErrors(SchemaIntf var1) {
  83.       super.checkForErrors(var1);
  84.       if (this.publicID != null && !DTDParser.isPubId(this.publicID)) {
  85.          super.errors.addElement(new ParserException(221, this.publicID));
  86.       }
  87.  
  88.    }
  89.  
  90.    public void setValue(String var1) {
  91.       String var2 = this.value;
  92.       this.value = var1;
  93.       this.systemID = null;
  94.       this.publicID = null;
  95.       ((BaseDeclaration)this).fireChangeEvent(51, var2);
  96.    }
  97.  
  98.    public boolean isInternal() {
  99.       return this.value != null;
  100.    }
  101.  
  102.    public boolean isPE() {
  103.       return false;
  104.    }
  105.  
  106.    public String getSource() {
  107.       StringBuffer var1 = new StringBuffer(String.valueOf(String.valueOf(String.valueOf("<!ENTITY ").concat(String.valueOf(this.isPE() ? "% " : ""))).concat(String.valueOf(super.name))).concat(String.valueOf(" ")));
  108.       if (this.value != null) {
  109.          var1.append(DTDUtilities.convertPEReferences(StringUtilities.doubleQuoted(this.value), true));
  110.       } else if (this.publicID != null) {
  111.          var1.append(String.valueOf(String.valueOf(String.valueOf("PUBLIC ").concat(String.valueOf(DTDUtilities.convertPEReferences(StringUtilities.doubleQuoted(this.publicID), true)))).concat(String.valueOf(" "))).concat(String.valueOf(DTDUtilities.convertPEReferences(StringUtilities.doubleQuoted(this.systemID.toSource()), true))));
  112.       } else {
  113.          var1.append(String.valueOf("SYSTEM ").concat(String.valueOf(DTDUtilities.convertPEReferences(StringUtilities.doubleQuoted(this.systemID.toSource()), true))));
  114.       }
  115.  
  116.       var1.append(String.valueOf(">").concat(String.valueOf(BaseDeclaration.LINE_SEPARATOR)));
  117.       return var1.toString();
  118.    }
  119. }
  120.